import 'package:animations/animations.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_app/bean/list_app_article_entity.dart';
import 'package:flutter_app/bean/list_dynamic_entity.dart';
import 'package:flutter_app/ui/home/search/search_view.dart';
import 'package:flutter_app/values/MyColors.dart';
import 'package:flutter_app/widget/custom_app_bar.dart';
import 'package:flutter_app/widget/empty_view.dart';
import 'package:flutter_screenutil/src/size_extension.dart';
import 'package:get/get.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';

import '../../../r.dart';
import 'home_logic.dart';

/**
 * @Description: 首页
 * @Author: 下雨了
 * @CreateDate: 2022年5月31日 13:59:55
 * @Version: 1.0
 */
///
class HomePage extends StatefulWidget {
  final String title;

  const HomePage({
    Key? key,
    required this.title,
  }) : super(key: key);

  @override
  _HomePageState createState() {
    return _HomePageState();
  }
}

class _HomePageState extends State<HomePage> {
  final logic = Get.put(HomeLogic());
  final state = Get.find<HomeLogic>().state;

  @override
  Widget build(BuildContext context) {
    return GetBuilder<HomeLogic>(builder: (logic) {
      return Scaffold(
        backgroundColor: MyColors.FFF1F1F1,
        body: Stack(
          children: [
            Image.asset(R.assetsImgBg112, fit: BoxFit.fitWidth),
            Column(
              children: [
                MyAppBar(context, title: "安徽效能监督员", isShowLeading: false),
                Expanded(
                  child: SmartRefresher(
                    header: WaterDropHeader(complete: Text('刷新完成', style: TextStyle(color: Colors.white))),
                    controller: logic.refreshController,
                    // 刷新
                    onRefresh: logic.onRefresh,
                    child: GestureDetector(
                      child: SingleChildScrollView(
                        child: Column(
                          children: [
                            /// 搜索
                            Container(
                              margin: EdgeInsets.only(top: 8.r, left: 16.r, right: 16.r),
                              decoration: BoxDecoration(
                                  borderRadius: BorderRadius.circular(4),
                                  color: MyColors.FFFFFFFF),
                              child: OpenContainer(
                                transitionDuration: Duration(milliseconds: 800),
                                closedElevation: 0,
                                closedBuilder: (BuildContext context, void Function() action) {
                                  return Container(
                                    height: 44.r,
                                    child: Row(
                                      children: [
                                        SizedBox(width: 12.r,),
                                        Expanded(
                                          child: Text("输入关键字进行搜索", style: TextStyle(color: MyColors.FF999999, fontSize: 13.sp,),),
                                        ),
                                        Image.asset(R.assetsImgIcon60, width: 16.r,),
                                        SizedBox(width: 12.r,),
                                      ],
                                    )
                                  );
                                },
                                openBuilder: (BuildContext context, void Function({Object? returnValue}) action) {
                                  return SearchPage();
                                },
                              ),
                            ),
                            /// 随手拍
                            Stack(
                              alignment: Alignment.bottomCenter,
                              children: [
                                Container(
                                  height: 113.r,
                                  width: Get.width,
                                  margin: EdgeInsets.only(top: 14.r, left: 16.r, right: 16.r),
                                  decoration: BoxDecoration(
                                    color: Colors.transparent,
                                    boxShadow: [
                                      BoxShadow(
                                          color: Color(0x26000000),
                                          blurRadius: 4.0.r,
                                          spreadRadius: 1.5.r,
                                          offset: Offset(0, 1.r),
                                          blurStyle: BlurStyle.normal
                                      ),
                                    ],
                                  ),
                                ),
                                InkWell(
                                  child: Container(
                                    height: 126.r,
                                    width: Get.width,
                                    margin: EdgeInsets.only(top: 14.r, left: 16.r, right: 16.r),
                                    decoration: BoxDecoration(
                                      color: Colors.transparent,
                                      image: DecorationImage(
                                        image: AssetImage(R.assetsImgBg8),
                                        fit: BoxFit.fill
                                      ),
                                    ),
                                    child: Container(
                                      margin: EdgeInsets.only(top: 31.r, left: 31.r, bottom: 15.r),
                                      child: Column(
                                        crossAxisAlignment: CrossAxisAlignment.start,
                                        children: [
                                          Text("随手拍", style: TextStyle(color: MyColors.FF1A4481, fontSize: 20.sp, fontWeight: FontWeight.w600),),
                                          SizedBox(height: 4.r,),
                                          Text("发现问题，一键拍照上传", style: TextStyle(color: MyColors.FF1A4481, fontSize: 12.sp, fontWeight: FontWeight.w600),),
                                          SizedBox(height: 7.r,),
                                          SizedBox(
                                            width: 70.r,
                                            height: 22.r,
                                            child: ElevatedButton(
                                              style: ElevatedButton.styleFrom(
                                                padding: EdgeInsets.all(0),
                                                primary: MyColors.FF2763B9,
                                              ),
                                              onPressed: () {
                                                logic.goToProblemReportPage();
                                              },
                                              child: Text("立即拍照", style: TextStyle(fontSize: 12.sp, color: Colors.white),),
                                            ),
                                          ),
                                        ],
                                      ),
                                    ),
                                  ),
                                  onTap: logic.goToProblemReportPage,
                                ),
                              ],
                            ),
                            /// 报名任务 执行任务
                            Container(
                              margin: EdgeInsets.only(top: 26.r, left: 16.r, right: 16.r, bottom: 16.r),
                              child: Row(
                                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                children: [
                                  InkWell(
                                    child: Container(
                                      height: 80.r,
                                      decoration: BoxDecoration(
                                        borderRadius: BorderRadius.circular(4.r),
                                      ),
                                      child: Stack(
                                        children: [
                                          Image.asset(R.assetsImgBg9, fit: BoxFit.fitHeight,),
                                          Positioned(
                                            top: 22.r,
                                            left: 14.r,
                                            child: Column(
                                              crossAxisAlignment: CrossAxisAlignment.start,
                                              children: [
                                                Text("报名效能活动", style: TextStyle(color: MyColors.FF3F4470, fontSize: 15.sp, fontWeight: FontWeight.w600),),
                                                SizedBox(height: 5.r,),
                                                Text("踊跃参与，共建效能", style: TextStyle(color: MyColors.FF3F4470, fontSize: 11.sp,)),
                                              ],
                                            ),
                                          ),
                                        ],
                                      ),
                                    ),
                                    onTap: () {
                                      logic.goToApplyPage();
                                    },
                                  ),
                                  InkWell(
                                    child: Container(
                                      height: 80.r,
                                      decoration: BoxDecoration(
                                        borderRadius: BorderRadius.circular(4.r),
                                      ),
                                      child: Stack(
                                        children: [
                                          Image.asset(R.assetsImgBg10, fit: BoxFit.fitHeight,),
                                          Positioned(
                                            top: 22.r,
                                            left: 14.r,
                                            child: Column(
                                              crossAxisAlignment: CrossAxisAlignment.start,
                                              children: [
                                                Text("执行明查暗访任务", style: TextStyle(color: MyColors.FF70491B, fontSize: 15.sp, fontWeight: FontWeight.w600),),
                                                SizedBox(height: 5.r,),
                                                Text("聚焦职责，提升效能", style: TextStyle(color: MyColors.FF70491B, fontSize: 11.sp),),
                                              ],
                                            ),
                                          ),
                                        ],
                                      ),
                                    ),
                                    onTap: () {
                                      logic.goToCollectPage();
                                    },
                                  ),
                                ],
                              ),
                            ),
                            /// 效能动态
                            Visibility(
                              visible: (state.listDynamicEntity?.length ?? 0) > 0,
                              child: Container(
                                width: Get.width,
                                padding: EdgeInsets.only(top: 16.r, left: 16.r, right: 16.r, bottom: 16.r),
                                decoration: BoxDecoration(
                                    color: Colors.white,
                                    borderRadius: BorderRadius.circular(4.r)
                                ),
                                child: Column(
                                  crossAxisAlignment: CrossAxisAlignment.start,
                                  children: [
                                    Text(
                                      "效能动态",
                                      style: TextStyle(
                                        color: MyColors.FF333333,
                                        fontSize: 18.sp,
                                        fontWeight: FontWeight.w600,
                                        decoration: TextDecoration.underline,
                                        decorationColor: MyColors.FFFF6938,
                                        decorationThickness: 3,
                                      ),
                                    ),
                                    /// 随手拍
                                    Visibility(
                                      visible: (logic.getListDynamic("1")?.length ?? 0) > 0,
                                      child: Container(
                                        margin: EdgeInsets.only(top: 12.r),
                                        padding: EdgeInsets.only(top: 16.r, left: 11.r, right: 16.r, bottom: 4.r),
                                        decoration: BoxDecoration(
                                            borderRadius: BorderRadius.circular(4.r),
                                            color: MyColors.FFF7F7F7
                                        ),
                                        child: Row(
                                          crossAxisAlignment: CrossAxisAlignment.start,
                                          children: [
                                            Container(
                                              margin: EdgeInsets.only(top: 6.r),
                                              child: Image.asset(R.assetsImgIcon61, width: 15.r),
                                            ),
                                            SizedBox(width: 5.r,),
                                            Expanded(
                                              child: Column(
                                                crossAxisAlignment: CrossAxisAlignment.start,
                                                children: [
                                                  Text("随手拍", style: TextStyle(color: MyColors.FF333333, fontSize: 16.sp, fontWeight: FontWeight.w600),),
                                                  ListView.separated(
                                                    itemBuilder: (BuildContext context, int index) {
                                                      return ListItem1(logic.getListDynamic("1")![index]);
                                                    },
                                                    itemCount: (logic.getListDynamic("1")?.length) ?? 0,
                                                    shrinkWrap: true, //解决无线高度问题 解决SingleChildScrollView 和listview冲突问题 ListView.builder
                                                    physics: NeverScrollableScrollPhysics(),
                                                    padding: EdgeInsets.only(top: 0),
                                                    separatorBuilder: (BuildContext context, int index) {
                                                      return Container(
                                                        height: 0.5.r,
                                                        color: MyColors.FFDDDDDD,
                                                      );
                                                    },
                                                  ),
                                                ],
                                              ),
                                            )
                                          ],
                                        ),
                                      ),
                                    ),
                                    /// 明察暗访任务
                                    Visibility(
                                      visible: (logic.getListDynamic("2")?.length ?? 0) > 0,
                                      child: Container(
                                        margin: EdgeInsets.only(top: 12.r),
                                        padding: EdgeInsets.only(top: 16.r, left: 11.r, right: 16.r, bottom: 4.r),
                                        decoration: BoxDecoration(
                                            borderRadius: BorderRadius.circular(4.r),
                                            color: MyColors.FFF7F7F7
                                        ),
                                        child: Row(
                                          crossAxisAlignment: CrossAxisAlignment.start,
                                          children: [
                                            Container(
                                              margin: EdgeInsets.only(top: 4.r),
                                              child: Image.asset(R.assetsImgIcon64, width: 15.r),
                                            ),
                                            SizedBox(width: 5.r,),
                                            Expanded(
                                              child: Column(
                                                crossAxisAlignment: CrossAxisAlignment.start,
                                                children: [
                                                  Text("明查暗访任务", style: TextStyle(color: MyColors.FF333333, fontSize: 16.sp, fontWeight: FontWeight.w600),),
                                                  ListView.separated(
                                                    itemBuilder: (BuildContext context, int index) {
                                                      return ListItem2(logic.getListDynamic("2")![index]);
                                                    },
                                                    itemCount: (logic.getListDynamic("2")?.length) ?? 0,
                                                    shrinkWrap: true, //解决无线高度问题 解决SingleChildScrollView 和listview冲突问题 ListView.builder
                                                    physics: NeverScrollableScrollPhysics(),
                                                    padding: EdgeInsets.only(top: 0),
                                                    separatorBuilder: (BuildContext context, int index) {
                                                      return Container(
                                                        height: 0.5.r,
                                                        color: MyColors.FFDDDDDD,
                                                      );
                                                    },
                                                  ),
                                                ],
                                              ),
                                            )
                                          ],
                                        ),
                                      ),
                                    ),
                                    /// 效能通知
                                    Visibility(
                                      visible: (logic.getListDynamic("3")?.length ?? 0) > 0,
                                      child: Container(
                                        margin: EdgeInsets.only(top: 12.r),
                                        padding: EdgeInsets.only(top: 16.r, left: 11.r, right: 16.r, bottom: 4.r),
                                        decoration: BoxDecoration(
                                            borderRadius: BorderRadius.circular(4.r),
                                            color: MyColors.FFF7F7F7
                                        ),
                                        child: Row(
                                          crossAxisAlignment: CrossAxisAlignment.start,
                                          children: [
                                            Container(
                                              margin: EdgeInsets.only(top: 8.r),
                                              child: Image.asset(R.assetsImgIcon62, width: 15.r),
                                            ),
                                            SizedBox(width: 5.r,),
                                            Expanded(
                                              child: Column(
                                                crossAxisAlignment: CrossAxisAlignment.start,
                                                children: [
                                                  Text("通知公告", style: TextStyle(color: MyColors.FF333333, fontSize: 16.sp, fontWeight: FontWeight.w600),),
                                                  ListView.separated(
                                                    itemBuilder: (BuildContext context, int index) {
                                                      return ListItem3(logic.getListDynamic("3")![index]);
                                                    },
                                                    itemCount: (logic.getListDynamic("3")?.length) ?? 0,
                                                    shrinkWrap: true, //解决无线高度问题 解决SingleChildScrollView 和listview冲突问题 ListView.builder
                                                    physics: NeverScrollableScrollPhysics(),
                                                    padding: EdgeInsets.only(top: 0),
                                                    separatorBuilder: (BuildContext context, int index) {
                                                      return Container(
                                                        height: 0.5.r,
                                                        color: MyColors.FFDDDDDD,
                                                      );
                                                    },
                                                  ),
                                                ],
                                              ),
                                            )
                                          ],
                                        ),
                                      ),
                                    ),
                                    /// 效能活动报名
                                    Visibility(
                                      visible: (logic.getListDynamic("4")?.length ?? 0) > 0,
                                      child: Container(
                                        margin: EdgeInsets.only(top: 12.r),
                                        padding: EdgeInsets.only(top: 16.r, left: 11.r, right: 16.r, bottom: 4.r),
                                        decoration: BoxDecoration(
                                            borderRadius: BorderRadius.circular(4.r),
                                            color: MyColors.FFF7F7F7
                                        ),
                                        child: Row(
                                          crossAxisAlignment: CrossAxisAlignment.start,
                                          children: [
                                            Container(
                                              margin: EdgeInsets.only(top: 6.r),
                                              child: Image.asset(R.assetsImgIcon63, width: 15.r),
                                            ),
                                            SizedBox(width: 5.r,),
                                            Expanded(
                                              child: Column(
                                                crossAxisAlignment: CrossAxisAlignment.start,
                                                children: [
                                                  Text("效能活动报名", style: TextStyle(color: MyColors.FF333333, fontSize: 16.sp, fontWeight: FontWeight.w600),),
                                                  ListView.separated(
                                                    itemBuilder: (BuildContext context, int index) {
                                                      return ListItem4(logic.getListDynamic("4")![index]);
                                                    },
                                                    itemCount: (logic.getListDynamic("4")?.length) ?? 0,
                                                    shrinkWrap: true, //解决无线高度问题 解决SingleChildScrollView 和listview冲突问题 ListView.builder
                                                    physics: NeverScrollableScrollPhysics(),
                                                    padding: EdgeInsets.only(top: 0),
                                                    separatorBuilder: (BuildContext context, int index) {
                                                      return Container(
                                                        height: 0.5.r,
                                                        color: MyColors.FFDDDDDD,
                                                      );
                                                    },
                                                  ),
                                                ],
                                              ),
                                            )
                                          ],
                                        ),
                                      ),
                                    ),
                                  ],
                                ),
                              ),
                            ),
                            /// 效能要闻
                            Container(
                              margin: EdgeInsets.only(top: 5.r, bottom: 5.r),
                              padding: EdgeInsets.only(left: 16.r, right: 16.r, top: 16.r, bottom: 16.r),
                              decoration: BoxDecoration(
                                  color: Colors.white,
                                  borderRadius: BorderRadius.circular(4.r)
                              ),
                              child: Column(
                                children: [
                                  Row(
                                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                    children: [
                                      Text("效能要闻",
                                        style: TextStyle(
                                          color: MyColors.FF333333,
                                          fontSize: 18.sp,
                                          fontWeight: FontWeight.w600,
                                          decoration: TextDecoration.underline,
                                          decorationColor: MyColors.FFFF6938,
                                          decorationThickness: 3,
                                        ),
                                      ),
                                      SizedBox(
                                        width: 46.r,
                                        height: 26.r,
                                        child: TextButton(
                                          onPressed: () {
                                            logic.goToNewsPage();
                                          },
                                          style: TextButton.styleFrom(
                                            padding: EdgeInsets.all(0),
                                              primary: MyColors.FFC30802,
                                          ),
                                          child: Text("更多", style: TextStyle(color: MyColors.FF777777, fontSize: 13.sp)),
                                        ),
                                      ),
                                    ],
                                  ),
                                  (state.listAppArticleEntity?.content?.length ?? 0) > 0 ? ListView.separated(
                                    itemBuilder: (BuildContext context, int index) {
                                      return NewsListItem(state.listAppArticleEntity!.content![index]);
                                    },
                                    itemCount: state.listAppArticleEntity!.content!.length,
                                    shrinkWrap: true, //解决无线高度问题 解决SingleChildScrollView 和listview冲突问题 ListView.builder
                                    physics: NeverScrollableScrollPhysics(),
                                    padding: EdgeInsets.only(top: 0),
                                    separatorBuilder: (BuildContext context, int index) {
                                      return Container(
                                        height: 0.5.r,
                                        color: MyColors.FFDDDDDD,
                                      );
                                    },
                                  ) : EmptyView(),
                                ],
                              ),
                            ),
                          ],
                        ),
                      ),
                      onTap: () {
                        // 空白处取消TextField焦点
                        FocusScopeNode currentFocus = FocusScope.of(context);
                        if (!currentFocus.hasPrimaryFocus && currentFocus.focusedChild != null) {
                          FocusManager.instance.primaryFocus!.unfocus();
                        }
                      },
                    ),
                  ),
                ),
              ],
            ),
          ],
        ),
      );
    });
  }

  /// 随手拍
  Widget ListItem1(ListDynamicDynamicVOList item) {
    return Container(
      margin: EdgeInsets.only(top: 12.r, bottom: 12.r),
      child: InkWell(
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Row(
              children: [
                Text("审核中", style: TextStyle(color: MyColors.FF329C34, fontSize: 12.sp),),
                Container(
                  width: 1.r,
                  height: 8.r,
                  color: MyColors.FF848484,
                  margin: EdgeInsets.only(left: 12.r, right: 12.r),
                ),
                Text(item.diffHour ?? "", style: TextStyle(color: MyColors.FF666666, fontSize: 12.sp),),
              ],
            ),
            SizedBox(height: 6.r,),
            Text(item.title ?? "", maxLines:1, style: TextStyle(color: MyColors.FF333333, fontSize: 15.sp),),
          ],
        ),
        onTap: () {
          logic.goToFilmDetail(item.id);
        },
      ),
    );
  }

  /// 明察暗访任务
  Widget ListItem2(ListDynamicDynamicVOList item) {
    return Container(
      margin: EdgeInsets.only(top: 12.r, bottom: 12.r),
      child: InkWell(
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Row(
              children: [
                Text("进行中", style: TextStyle(color: MyColors.FF329C34, fontSize: 12.sp),),
                Container(
                  width: 1.r,
                  height: 8.r,
                  color: MyColors.FF848484,
                  margin: EdgeInsets.only(left: 12.r, right: 12.r),
                ),
                Text(item.diffHour ?? "", style: TextStyle(color: MyColors.FF666666, fontSize: 12.sp),),
              ],
            ),
            SizedBox(height: 6.r,),
            Text(item.title ?? "", maxLines:1, style: TextStyle(color: MyColors.FF333333, fontSize: 15.sp),),
          ],
        ),
        onTap: () {
          logic.goToCollectDetailPage(item.id);
        },
      ),
    );
  }

  /// 通知公告
  Widget ListItem3(ListDynamicDynamicVOList item) {
    return Container(
      margin: EdgeInsets.only(top: 12.r, bottom: 12.r),
      child: InkWell(
        child: Row(
          children: [
            Container(
              width: 5.r,
              height: 5.r,
              decoration: BoxDecoration(
                  color: MyColors.FFF03F35,
                  borderRadius: BorderRadius.circular(5.r)),
            ),
            SizedBox(width: 6.r,),
            Flexible(
              child: Text(
                item.title ?? "",
                maxLines: 1,
                style: TextStyle(color: MyColors.FF333333, fontSize: 15.sp),
              ),
            ),
          ],
        ),
        onTap: () {
          logic.goToMsgDetailPage(item.id);
        },
      ),
    );
  }

  /// 效能活动报名
  Widget ListItem4(ListDynamicDynamicVOList item) {
    return Container(
      margin: EdgeInsets.only(top: 12.r, bottom: 12.r),
      child: InkWell(
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Row(
              children: [
                Text("未报名", style: TextStyle(color: MyColors.FF329C34, fontSize: 12.r),),
                Container(
                  width: 1.r,
                  height: 8.r,
                  color: MyColors.FF848484,
                  margin: EdgeInsets.only(left: 12.r, right: 12.r),
                ),
                Text(item.diffHour ?? "", style: TextStyle(color: MyColors.FF666666, fontSize: 12.sp),),
              ],
            ),
            SizedBox(height: 6.r,),
            Text(item.title ?? "", maxLines:1, style: TextStyle(color: MyColors.FF333333, fontSize: 15.sp),),
          ],
        ),
        onTap: () {
          logic.goToApplyDetailPage(item.id);
        },
      ),
    );
  }

  Widget NewsListItem(ListAppArticleContent item) {
    return Container(
      padding: EdgeInsets.only(top: 20.r, bottom: 20.r),
      child: IntrinsicHeight(
        child: InkWell(
          child: item.pictureList!.length == 1 ? Row(
            children: [
              Expanded(
                child: Container(
                  padding: EdgeInsets.only(top: 1.r, bottom: 1.r),
                  margin: EdgeInsets.only(right: 13.r),
                  child: Column(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      Text(item.title ?? "",
                        style: TextStyle(color: Colors.black, fontSize: 16.sp,
                            fontWeight: FontWeight.w500, height: 1.2.r,
                        ),
                        textAlign: TextAlign.justify,
                        maxLines: 3,
                        overflow: TextOverflow.ellipsis,
                      ),
                      Container(
                        child: Row(
                          crossAxisAlignment: CrossAxisAlignment.end,
                          children: [
                            Flexible(child: Text(item.xSource ?? "", maxLines: 1, style: TextStyle(color: MyColors.FF999999, fontSize: 12.sp),)),
                            SizedBox(width: 5.r,),
                            Text(item.publishTime ?? "", style: TextStyle(color: MyColors.FF999999, fontSize: 12.sp),)
                          ],
                        ),
                      )
                    ],
                  ),
                ),
              ),
              SizedBox(
                height: 90.r,
                width: 110.r,
                child: ClipRRect(
                  borderRadius: BorderRadius.circular(4.r),
                  child: Image.network(
                    item.pictureList?[0].thumbnailPath ?? "",
                    fit: BoxFit.cover,
                  ),
                ),
              ),
            ],
          )
          : item.pictureList!.length > 1 && item.pictureList!.length < 4 ?
          Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Text(item.title ?? "",
                style: TextStyle(color: Colors.black, fontSize: 16.sp, fontWeight: FontWeight.w500, height: 1.2.r,),
                maxLines: 2,
                textAlign: TextAlign.justify,
                overflow: TextOverflow.ellipsis,
              ),
              Container(
                margin: EdgeInsets.only(top: 8.r),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    for (ListAppArticleContentPictureList picture in item.pictureList!)
                      SizedBox(
                        height: 90.r,
                        width: 110.r,
                        child: ClipRRect(
                          borderRadius: BorderRadius.circular(4.r),
                          child: Image.network(
                            picture.thumbnailPath ?? "",
                            fit: BoxFit.cover,
                          ),
                        ),
                      ),
                  ],
                ),
              ),
              Container(
                margin: EdgeInsets.only(top: 8.5.r),
                child: Row(
                  crossAxisAlignment: CrossAxisAlignment.end,
                  children: [
                    Flexible(child: Text(item.xSource ?? "", maxLines: 1, style: TextStyle(color: MyColors.FF999999, fontSize: 12.sp),)),
                    SizedBox(width: 5.r,),
                    Text(item.publishTime ?? "", style: TextStyle(color: MyColors.FF999999, fontSize: 12.sp),)
                  ],
                ),
              )
            ],
          )
          : Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Text(item.title ?? "",
                style: TextStyle(color: Colors.black, fontSize: 16.sp, fontWeight: FontWeight.w500, height: 1.2.r),
                maxLines: 2,
                textAlign: TextAlign.justify,
                overflow: TextOverflow.ellipsis,
              ),
              Container(
                margin: EdgeInsets.only(top: 7.5.r),
                child: Text((item.content ?? "").trim(),
                  style: TextStyle(color: MyColors.FF333333, fontSize: 13.sp, height: 1.25.r),
                  maxLines: 2,
                  textAlign: TextAlign.justify,
                  overflow: TextOverflow.ellipsis,
                ),
              ),
              Container(
                margin: EdgeInsets.only(top: 8.5.r),
                child: Row(
                  crossAxisAlignment: CrossAxisAlignment.end,
                  children: [
                    Text(item.xSource ?? "", style: TextStyle(color: MyColors.FF999999, fontSize: 12.sp),),
                    SizedBox(width: 5.r,),
                    Text(item.publishTime ?? "", style: TextStyle(color: MyColors.FF999999, fontSize: 12.sp),)
                  ],
                ),
              )
            ],
          ),
          onTap: () {
            logic.goToNewsDetailPage(item.id);
          }
        ),
      ),
    );
  }

  @override
  void dispose() {
    Get.delete<HomeLogic>();
    super.dispose();
  }
}
